package org.rambadger.command.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * The string is used in URLs and database identifiers. The string must be between 1 and 32 characters long, and is limited to lowercase letters, numbers, underscores, and hyphens. The first letter must be a lowercase letter.
 */
@Target({ METHOD, FIELD, ANNOTATION_TYPE, PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = {UrlIdentifierValidator.class, UrlIdentifierValidator.UrlIdentifierCollectionValidator.class})
@Documented
public @interface UrlIdentifier {
    String regexp() default "^[a-z][a-z0-9_\\-]*$";
    int minLength() default DefaultConstraintValues.URL_IDENTIFIER_LENGTH_MIN;
    int maxLength() default DefaultConstraintValues.URL_IDENTIFIER_LENGTH_MAX;

    String message() default "{org.rambadger.command.validation.UrlIdentifier}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}
